﻿using M.ShopMachine.Domain;
using M.ShopMachine.Read.WebApi.Application.Command.DeviceCommand;
using M.ShopMachine.Repository.Interface;
using MediatR;

namespace M.ShopMachine.Read.WebApi.Application.Handler.DeviceHandler
{
    public class GetFormDeviceHandler : IRequestHandler<GetFormDeviceCommand, Device>
    {
        private readonly IDeviceRepository deviceRepository;

        public GetFormDeviceHandler(IDeviceRepository deviceRepository)
        {
            this.deviceRepository = deviceRepository;
        }

        public async Task<Device> Handle(GetFormDeviceCommand request, CancellationToken cancellationToken)
        {
            return await deviceRepository.GetFormDeviceAsync(request.id);
        }
    }
}
